// Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov  Date: 27/11/2008 22:56:56
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   GameGrid.java

package reversi;

import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JComponent;

// Referenced classes of package reversi:
//            GameState, MainWindow

public class GameGrid extends JComponent
{

    public GameGrid(GameState gamestate)
    {
        images = new Image[2];
        listeners = 0;
        markData = gamestate;
        Dimension dimension = new Dimension(gamestate.getWidth() * 54, gamestate.getHeight() * 54);
        setSize(dimension);
        setPreferredSize(dimension);
        images[0] = MainWindow.icons[0].getImage();
        images[1] = MainWindow.icons[1].getImage();
    }

    public void paint(Graphics g)
    {
        g.setColor(getForeground());
        for(int i = 0; i < markData.getWidth(); i++)
        {
            for(int j = 0; j < markData.getHeight(); j++)
            {
                int k = markData.getMarkAt(i, j);
                int l = i * 54;
                int i1 = (l + 54) - 1;
                int j1 = j * 54;
                int k1 = (j1 + 54) - 1;
                if(k != -1)
                    g.drawImage(images[k], l + 2, j1 + 2, this);
                g.drawLine(l, k1, i1, k1);
                g.drawLine(i1, j1, i1, k1);
            }

        }

    }

    GameState markData;
    Image images[];
    int listeners;
    final int gridSizeX = 54;
    final int gridSizeY = 54;
}